﻿<include file="top" />
<form class="nav"><input type="button" onclick="window.location='?m=MediaMessages';" value="常用消息" /> &nbsp; <input type="button" onclick="ShowEditRules(0);" value="添加新规则" /></form>
<table width="100%">
	<tr class="h"><td width="100">规则名称</td><td width="160">响应对象</td><td>响应内容</td><td width="80">创建时间</td>
	<td width="80">修改时间</td><td width="40">优先级</td><td width="100">状态</td><td width="70">详情</td></tr>
<loop name="Rules">
	<tr class="l">
		<td width="100">{$Rules.Name:F.encodeHTML}</td>
		<td>{$Rules.Delegate}</td>
		<td>
			<expression and="Rules.MsgId:IsNumeric eq true as bool">
				常用消息(<a onclick="ShowMediaMessage({$Rules.MsgId});">{$Rules.MsgId}</a>)
			<else and="Rules.MsgId eq TEXT" />
				普通文本：{$Rules.Details:F.encodeHTML}
			</else>
			{$Rules.MsgId}</expression>
		</td>
		<td>{$Rules.CreateAt:F.untimespan="yyyy-MM-dd"}</td>
		<td>{$Rules.ModifyAt:F.untimespan="yyyy-MM-dd"}</td>
		<td>{$Rules.Priority}</td>
		<td><eq name="Rules.Disabled" value="0" type="number">
			已启用(<a href="?m=ResponseRules&a=disable&Id={$Rules.Id}&state=1">禁用</a>)
			</else>
			<span class="red">已禁用</span>(<a href="?m=ResponseRules&a=disable&Id={$Rules.Id}&state=0">启用</a>)
			</eq></td>
		<td><a onclick="ShowEditRules({$Rules.Id});">修改</a> |
		<a href="?m=ResponseRules&a=delete&Id={$Rules.Id}" onclick="return window.confirm('确定要删除本记录吗？');">删除</a></td>
	</tr>
</loop>
	<tr class="l"><td colspan="8"><page for="Rules" /></td></tr>
</table>
<script type="text/javascript">
function ShowHelp(selc){
	var option = selc.options[selc.selectedIndex];
	if(option){
		F("#func-help").html("功能说明："+F.decode(F(option).attr("rel")||"无"));
	}else{
		F("#func-help").html("");
	}
	if(selc.value=="TEXT"){
		F(".TextResponse").css({"display":""});
	}else{
		F(".TextResponse").css({"display":"none"});
	}
}
function ShowEditRules(Id){
	Ajax({
		url:"?m=ResponseRules&a=edit&Id=" + Id,
		succeed:function(msg){
			F("#DialogAlert").attr("title","添加/修改规则").html(msg).dialog({
				"width":575,"height":500,buttons:{
					"保存规则":function(){
						SendMessage(document.forms['frm_saverules']);
						return false;
					}
				},afterOpen:function(){
					ShowHelp(document.forms['frm_saverules']['MsgId']);
					new wechatEditor('message_intro', {emotionPath : '/Contents/Emotions/'});
				}
			});
		}
	});
}
</script>
<div id="DialogAlert"></div>
<js file="/Contents/Scripts/jquery.min.js" />
<js file="/Contents/Scripts/wxeditor.js" />
<include file="foot" />